define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'normalplatcourse/index' + location.search,
                    add_url: 'normalplatcourse/add',
                    edit_url: 'normalplatcourse/edit',
                    // del_url: 'normalplatcourse/del',
                    multi_url: 'normalplatcourse/multi',
                    table: 'learn_course_orgpay',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        //{checkbox: true},
                        {field: 'id', title: '序号'},
                        {field: 'learncourse.name', title: '课程名称'},
                        // {field: 'course_id', title: __('Course_id')},
                        // {field: 'org_cate_id', title: __('Org_cate_id')},
                        // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'origin_price', title: '原价', operate:'BETWEEN'},
                        {field: 'price', title: '现价', operate:'BETWEEN'},
                        // {field: 'learncourse.id', title: __('Learncourse.id')},
                        // {field: 'learncourse.number', title: __('Learncourse.number')},
                        // {field: 'learncourse.introduce', title: __('Learncourse.introduce')},
                        // {field: 'learncourse.origin_price', title: __('Learncourse.origin_price'), operate:'BETWEEN'},
                        // {field: 'learncourse.price', title: __('Learncourse.price'), operate:'BETWEEN'},
                        // {field: 'learncourse.visitor_origin_price', title: __('Learncourse.visitor_origin_price'), operate:'BETWEEN'},
                        // {field: 'learncourse.visitor_price', title: __('Learncourse.visitor_price'), operate:'BETWEEN'},
                        // {field: 'learncourse.buy_numbers', title: __('Learncourse.buy_numbers')},
                        {field: 'learncourse.image', title: '封面图', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'learncourse.thumbs', title: __('Learncourse.thumbs')},
                        // {field: 'learncourse.author', title: __('Learncourse.author')},
                        // {field: 'learncourse.status', title: __('Learncourse.status')},
                        // {field: 'learncourse.createtime', title: __('Learncourse.createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'learncourse.org_cate_id', title: __('Learncourse.org_cate_id')},
                        // {field: 'learncourse.type', title: __('Learncourse.type')},
                        // {field: 'learncourse.is_buy', title: __('Learncourse.is_buy')},
                         {field: 'learncourse.sort', title: '排序'},
                        // {field: 'learncourse.is_chat', title: __('Learncourse.is_chat')},
                        // {field: 'learncourse.file', title: __('Learncourse.file')},
                        // {field: 'learncourse.teacher_id', title: __('Learncourse.teacher_id')},
                        // {field: 'learncourse.is_single', title: __('Learncourse.is_single')},
                        // {field: 'learncourse.is_system', title: __('Learncourse.is_system')},
                        // {field: 'learncourse.adminid', title: __('Learncourse.adminid')},
                        // {field: 'learncourse.series_id', title: __('Learncourse.series_id')},
                        // {field: 'learncourse.special', title: __('Learncourse.special')},
                        // {field: 'learncourse.is_hot', title: __('Learncourse.is_hot')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                pagination: false,
                showToggle: false,
                showColumns: false,
                showExport: false,
                searchFormVisible: false,
                search:false,
                commonSearch:false,
                onLoadSuccess:function(){
                    // 这里就是数据渲染结束后的回调函数
                    $(".btn-editone").data("area", ["100%","100%"]);
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});